package com.guet.game.component;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;

import com.guet.game.World;
import com.guet.game.airplanes.dao.FlyingObj;
import com.guet.game.utils.Images;
import com.guet.game.weapon.Bullet;

public class Hpbar extends FlyingObj {
	int maxvalue=0;
	int value=0;
	int atktayp=0;
	public Hpbar(int hp){
		super(100,32,0,World.HEIGHT-70);
		maxvalue=hp;
		value=hp;
	}
	@Override
	public BufferedImage getImage() {
		// TODO Auto-generated method stub
		return Images.hpFill;
	}
	@Override
	public void paintObj(Graphics g) {
		// TODO Auto-generated method stub
		  	g.drawImage(Images.hpBg, 0,World.HEIGHT-70, null);
	        g.drawImage(Images.hpFill, this.x, this.y, null);
	        g.drawImage(Images.atkFire[atktayp], 0,World.HEIGHT-90, null);
	}
	@Override
	public void move() {
		// TODO Auto-generated method stub
	}
	public void gethp(int hp,int atk) {
		//System.out.println(x);
		if(hp>maxvalue) {
			maxvalue=hp;
			value=hp;
		}else {
			value=hp;
		}
		x=(int)((float)-420*((float)1-(float)value/(float)maxvalue));
		 if (atk == 1) {
			 atktayp=0;
	        } else if (atk < 100) {
	        	atktayp=1;
	        } else if (atk < 200) {
	        	atktayp=2;
	        } else {
	        	atktayp=3;
	        }
	}
}
